import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

// const routes = [
//   {
//     path: "/",
//     redirect: "/newsList",
//     meta: {
//       title: "重定向",
//       hidden: true
//     }
//   },
//   {
//     path: "/newsList",
//     name: "newsList",
//     meta: {
//       title: "新闻列表"
//     },
//     component: () => import(/* webpackChunkName: "about" */ '../views/newsList.vue')
//   },
//   {
//     path: "/newsType",
//     name: "newsType",
//     meta: {
//       title: "新闻分类"
//     },
//     component: () => import(/* webpackChunkName: "about" */ '../views/newsType.vue')
//   },
//   {
//     path: "/users",
//     name: "users",
//     meta: {
//       title: "用户管理"
//     },
//     component: () => import(/* webpackChunkName: "about" */ '../views/users.vue')
//   },
//   {
//     path: "/swiperMgr",
//     name: "swiperMgr",
//     meta: {
//       title: "轮播图管理"
//     },
//     component: () => import(/* webpackChunkName: "about" */ '../views/swiperMgr.vue')
//   },
//   {
//     path: "/login",
//     name: "login",
//     meta: {
//       title: "登录",
// 	  hidden: true
//     },
//     component: () => import(/* webpackChunkName: "about" */ '../views/login.vue')
//   }
// ]
const routes = [
	// {
	// 	path: "/",
	// 	redirect: "/login",
	// 	meta: {
	// 		title: "重定向",
	// 		hidden: true
	// 	}
	// },
	{
		path: "/login",
		name: 'login',
		meta: {
			title: "登录"
		},
		component: () => import('../views/login.vue')
	},
	{
		path: "/",
		name: 'zhuye',
		meta: {
			title: "主页"
		},
		component: () => import('../views/Zhuye.vue'),
		children: [{
				path: "",
				redirect: "newsList",
				meta: {
					title: "重定向",
					hidden: true
				}
			},
			{
				path: "newsList",
				name: "newsList",
				meta: {
					title: "新闻列表",
					icon: require('@/assets/icon/newsList_icon.png'),
					icon_sl: require('@/assets/icon/newsList_icon_sl.png'),
				},
				component: () => import( /* webpackChunkName: "about" */ '../views/newsList.vue')
			},
			{
				path: "newsType",
				name: "newsType",
				meta: {
					title: "新闻分类",
					icon: require('@/assets/icon/newsType_icon.png'),
					icon_sl: require('@/assets/icon/newsType_icon_sl.png'),
				},
				component: () => import( /* webpackChunkName: "about" */ '../views/newsType.vue')
			},
			{
				path: "users",
				name: "users",
				meta: {
					title: "用户管理",
					icon: require('@/assets/icon/users_icon.png'),
					icon_sl: require('@/assets/icon/users_icon_sl.png'),
				},
				component: () => import( /* webpackChunkName: "about" */ '../views/users.vue')
			},
			{
				path: "swiperMgr",
				name: "swiperMgr",
				meta: {
					title: "轮播图管理",
					icon: require('@/assets/icon/swiperMgr_icon.png'),
					icon_sl: require('@/assets/icon/swiperMgr_icon_sl.png'),
				},
				component: () => import( /* webpackChunkName: "about" */ '../views/swiperMgr.vue')
			},
		]
	},

]

const router = new VueRouter({
	routes,
	// 修改路径方式history/hash/
	mode:"history"
})

router.beforeEach((to, from, next) => {
	window.document.title = 'rain_' + to.meta.title;
	next();
})

export default router
